package com.fwh.gmall.controller;

import com.fwh.gmall.dto.User;
import com.fwh.gmall.service.UserService;
import org.springframework.web.bind.annotation.*;
import com.fwh.gmall.base.Result; // 根据实际路径修改

@RestController
@RequestMapping("jdbc")
public class DorisJdbcController {
    private final UserService userService;

    public DorisJdbcController(UserService userService) {
        this.userService = userService;
    }
    // 插入不了doris
    @PostMapping("save")
    public Result save(@RequestBody User user){
        userService.save(user);
        return Result.success();
    }


    @GetMapping("get/{id}")
    public Result getById(@PathVariable Integer id){
        return Result.success(userService.getUserById(id));
    }

    @GetMapping("list")
    public Result list(){
        return Result.success(userService.listUser());
    }

    @GetMapping("delete/{id}")
    public Result delete(@PathVariable Integer id){
        userService.delete(id);
        return Result.success();
    }
}
